<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>分享链接</title>
    <script src="js/jquery/jquery-3.4.1.min.js"></script>
    <script type="text/javascript" src="http://cdn.staticfile.org/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
</head>
<style>
    .button{
        width: 150px;
        height: 40px;
        color: #6c4aa1;
        font-size: 20px;
        margin-top: 5%;
        border: 1px solid grey;
        cursor: pointer;
    }
</style>
<body>
<div style="margin: 5% 40%">
  <h2>分享二维码或链接给好友以进行收件</h2><br>
    <div>
        <div id="qrcode"></div><br>
        <label>收件地址：</label>
        <span id="link" style="width: auto"></span>
    </div>
    <input type="button" value="返回主页" class="button" id="butt">
</div>
</body>
<script>
    function getQueryString(name) {
        let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        let r = window.location.search.substr(1).match(reg);
        if (r != null) {
            return decodeURIComponent(r[2]);
        }
        return "";
    }

    function outputCod(txt){
        $('#qrcode').empty();
        $("#qrcode").qrcode({
            render:"canvas",
            width:300,
            height:300,
            text:txt
        })
    }

    $(function () {
        var txt = "http://" + window.location.host + "/upload_file?folder_key="+getQueryString("folder_key")
        document.getElementById("link").innerText = txt
        outputCod(txt)

        $('#butt').click(function () {
            location.href="/index"
        })
    })

</script>
</html>